package com.ekuaitu.kuaitu.activity;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ekuaitu.kuaitu.R;
import com.ekuaitu.kuaitu.base.BaseActivity;
import com.ekuaitu.kuaitu.utils.KuaituDialog;
import com.ekuaitu.kuaitu.utils.MyApplication;
import com.ekuaitu.kuaitu.utils.StatusBarUtil;
import com.umeng.message.PushAgent;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.OnClick;

public class AboutActivity extends BaseActivity {

    @BindView(R.id.return_about)
    ImageView returnAbout;
    @BindView(R.id.toolbar_about)
    Toolbar toolbarAbout;
    @BindView(R.id.imageView)
    ImageView imageView;
    @BindView(R.id.about_version)
    TextView aboutVersion;
    @BindView(R.id.about_phone)
    TextView aboutPhone;
    @BindView(R.id.about_rl_phone)
    AutoRelativeLayout aboutRlPhone;
    private Context mContext = this;
    private PushAgent mPushAgent;

    @Override
    public int getLayoutId() {
        return R.layout.activity_about;
    }

    @Override
    public void initView() {
        StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimaryWhite), 0, true);
        aboutVersion.setText("当前版本:" + MyApplication.getInstance().getAppVersion());
        aboutPhone.setText(MyApplication.getInstance().getHotLine());
        mPushAgent = PushAgent.getInstance(this);
        mPushAgent.onAppStart();
    }

    @OnClick({R.id.about_rl_phone, R.id.return_about})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.return_about:
                finish();
                break;
            case R.id.about_rl_phone:
                final KuaituDialog kuaituDialog2 = new KuaituDialog(mContext);
                kuaituDialog2.setTitle(getString(R.string.dialogTitle));
                kuaituDialog2.setMessage("是否拨打客服电话" + MyApplication.getInstance().getHotLine());
                kuaituDialog2.setYesOnclickListener("确定", new KuaituDialog.onYesOnclickListener() {
                    @Override
                    public void onYesClick() {
                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_DIAL);
                        intent.setData(Uri.parse("tel:" + MyApplication.getInstance().getHotLine()));
                        startActivity(intent);
                        kuaituDialog2.dismiss();
                    }
                });
                kuaituDialog2.setNoOnclickListener("取消", new KuaituDialog.onNoOnclickListener() {
                    @Override
                    public void onNoClick() {
                        kuaituDialog2.dismiss();
                    }
                });
                kuaituDialog2.show();
                break;
        }
    }
}
